import {BaseApi, MSuccess} from "@/api/base";
import {reactive} from "vue";
import request from '@/utils/request'

export const rest = new class Restful extends BaseApi{
    base='/api/v1/restful'
    Run = async (data) => {
        var resp = reactive({})
        await request({
            url: this.base+"/run", method: 'post', data: data,
        }).then((response) => {
            MSuccess(response)
            resp = response.data
        })
        return resp
    }

    List = async (query) => {
        var data = []
        var url = this.base
        if (query != undefined) {
            url = url +"?"
            for (var k in query) {
                if (query[k] != undefined) {
                    url = url + "&" + k + "=" + query[k]
                }
            }
        }
        await request({
            url: url, method: 'get',
        }).then((response) => {
            data = response.data.data
        })
        return data
    }
}

export const rest_meau = new class RestfulMeau extends BaseApi{
    base='/api/v1/restful/meau'
    List = async (query) => {
        var data = []
        var url = this.base
        if (query != undefined) {
            url = url +"?"
            for (var k in query) {
                if (query[k] != undefined) {
                    url = url + "&" + k + "=" + query[k]
                }
            }
        }
        await request({
            url: url, method: 'get',
        }).then((response) => {
            data = response.data.data
        })
        return data
    }
}